﻿<UserControl x:Class="Peter.Sdw.View.TermListView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:controls="clr-namespace:Peter.Common.Controls;assembly=Peter.Common"
             xmlns:icons="clr-namespace:Peter.Common.Icons;assembly=Peter.Common"
             xmlns:logic="clr-namespace:Peter.Sdw.Logic"
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300"
             d:DataContext="{d:DesignInstance logic:TermListModel}">
   <Grid>
      <Grid.RowDefinitions>
         <RowDefinition Height="Auto" />
         <RowDefinition Height="Auto" />
         <RowDefinition Height="*" />
         <RowDefinition Height="Auto" />
      </Grid.RowDefinitions>

      <TextBlock Text="Terms"
                 FontWeight="Bold" />
      <TextBox Text="{Binding Path=TermSearch, UpdateSourceTrigger=PropertyChanged}"
               Grid.Row="1">
         <controls:WatermarkService.Watermark>
            <TextBlock Text="Search..."
                       Margin="4" />
         </controls:WatermarkService.Watermark>
      </TextBox>

      <ListBox Grid.Row="2"
               controls:Ex.ExecuteCommand="{Binding Path=OpenTermCommand}"
               SelectedItem="{Binding Path=SelectedTerm}"
               ItemsSource="{Binding Path=Terms}">
         <ListBox.ItemTemplate>
            <DataTemplate>
               <TextBlock Text="{Binding Path=Name}" />
            </DataTemplate>
         </ListBox.ItemTemplate>
      </ListBox>

      <Grid Grid.Row="3">
         <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*" />
            <ColumnDefinition Width="*" />
            <ColumnDefinition Width="*" />
            <ColumnDefinition Width="*" />
         </Grid.ColumnDefinitions>

         <Button Grid.Column="0"
                 CommandParameter="prev"
                 ToolTip="Previous Results"
                 Command="{Binding Path=NavigateListCommand}">
            <icons:IconDisplay Icon="Previous" />
         </Button>

         <Button Grid.Column="1"
                 ToolTip="Refresh List"
                 Command="{Binding Path=RefreshCommand}"
                 Visibility="{Binding Path=ShowAdd, Converter={StaticResource _BoolToVisi}}">
            <icons:IconDisplay Icon="Refresh" />
         </Button>

         <Button Grid.Column="2"
                 ToolTip="Create a new Term"
                 Command="{Binding Path=AddTermCommand}"
                 Visibility="{Binding Path=ShowAdd, Converter={StaticResource _BoolToVisi}}">
            <icons:IconDisplay Icon="Createfile" />
         </Button>

         <Button Grid.Column="3"
                 ToolTip="Next Results"
                 CommandParameter="next"
                 Command="{Binding Path=NavigateListCommand}">
            <icons:IconDisplay Icon="Next" />
         </Button>
      </Grid>

      <Border Grid.Row="0"
              Grid.RowSpan="4"
              Height="75"
              Width="150"
              CornerRadius="5"
              Background="SteelBlue"
              Visibility="{Binding Path=IsLoading, Converter={StaticResource _BoolToVisi}}">
         <TextBlock Text="Loading..."
                    FontSize="16"
                    Foreground="White"
                    FontStyle="Italic"
                    HorizontalAlignment="Center"
                    VerticalAlignment="Center" />
      </Border>
   </Grid>
</UserControl>
